package com.surveycomp.servlets;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;

public class ServletUtils {

	public static long getLong(String s, HttpServletRequest req) {
		long returnLong = 0;
		try {
			returnLong = Long.parseLong(req.getParameter(s));
		} catch (Exception e) {
		}
		return returnLong;
	}

	public static int getInt(String s, HttpServletRequest req) {
		int returnInt = 0;
		try {
			returnInt = Integer.parseInt(req.getParameter(s));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnInt;
	}

	public static long getLongDate(String string, HttpServletRequest req,
			String dateformat) throws ParseException {

		return new SimpleDateFormat(dateformat).parse(req.getParameter(string))
				.getTime();
	}
}
